package com.youxin.cpcenter.service.impl;

import com.youxin.busfoundation.bean.ResponseObject;
import com.youxin.busfoundation.bean.ent.RequestCompanyCorrectionBean;
import com.youxin.busfoundation.utils.DateTimeBusUtils;
import com.youxin.cpcenter.dao.TbCompanyCorrectionInfoMapper;
import com.youxin.cpcenter.model.TbCompanyCorrectionInfo;
import com.youxin.cpcenter.service.CompanyCorrectionInfoService;
import com.youxin.foundation.db.utils.KeyGenerationUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName: CompanyCorrectionInfoServiceImpl
 * @Description: 企业画像-纠错
 * @author Kris.wang
 * @date 2017年11月30日 下午14:01:02
 */
@Service("CompanyCorrectionInfoService")
public class CompanyCorrectionInfoServiceImpl implements CompanyCorrectionInfoService {

    @Autowired
    private TbCompanyCorrectionInfoMapper tbCompanyCorrectionInfoMapper;

    /**
     * @desc 企业画像-企业纠错
     * @param bean
     * @return
     */
    @Transactional(propagation = Propagation.REQUIRED)
    @Override
    public ResponseObject companyCorrection(RequestCompanyCorrectionBean bean){
        // 纠错信息
        TbCompanyCorrectionInfo tbCompanyCorrectionInfo = new TbCompanyCorrectionInfo();
        tbCompanyCorrectionInfo.setId(KeyGenerationUtils.generateKey());
        tbCompanyCorrectionInfo.setMemberUid(bean.getMemberUid());
        tbCompanyCorrectionInfo.setCompanyUid(bean.getCompanyUid());
        tbCompanyCorrectionInfo.setInfo(bean.getInfo());
        tbCompanyCorrectionInfo.setAddTime(DateTimeBusUtils.getTimeSecondsInt());

        int rowEffected = tbCompanyCorrectionInfoMapper.insertSelective(tbCompanyCorrectionInfo);
        if (rowEffected != 1) {
            return ResponseObject.userFailure("操作失败!");
        }

        return ResponseObject.successObject();
    }
}
